
const dateUtils = require('../../utils/defautils')
const utils = require("../../utils/index.js")
const {
SendverificationCode,
register,
option,
    smscode,
follow
} = require('../../api/login.js')
const {
    levelOption,
    sheng,
} = require('../../api/index.js')
Page({
data: {
     merchantAccount:'',
     merchantPassword:'',
     merchantName:'',
     contactNumber:'',
     merchantAddress:'',
    headportrait:'',
    tempPathheadportrait:'../../static/upload.png',
     shhf:'',
    registerContainerClass: "",

},

async onLoad() {











},
onUnload() {
},
async onShow() {









},







async  register(){
if (this.data.merchantAccount == "") {
wx.showToast({
title: '请输入商家账号',
icon: "none"
})
return;
}
if (this.data.merchantPassword == "") {
wx.showToast({
title: '请输入商家密码',
icon: "none"
})
return;
}
if (this.data.merchantPassword2=="") {
wx.showToast({
title: '请输入确认商家密码',
icon: "none"
})
return;
}
if (this.data.merchantPassword !== this.data.merchantPassword2) {
wx.showToast({
title: '商家密码与确认商家密码不一致!!',
icon: "none"
})
return;
}
if (this.data.contactNumber == "") {
wx.showToast({
title: '请输入联系电话',
icon: "none"
})
return;
}
        if (!utils.validata("contactNumber",this.data.contactNumber)) {
        wx.showToast({
            title: '请输入有效联系电话',
            icon: 'none'
        })
        return;
    }











    const regex = new RegExp(wx.getStorageSync("baseURL"), "g");
  const resultObj={
        merchantAccount:this.data.merchantAccount,
        merchantPassword:this.data.merchantPassword,
        merchantName:this.data.merchantName,
        contactNumber:this.data.contactNumber,
        merchantAddress:this.data.merchantAddress,
        headportrait:this.data.headportrait.replace(regex, ""),
        sfsh:this.data.sfsh,
        shhf:this.data.shhf,
  }
    const name="merchantAccount"
    const password="merchantPassword"
    const res = await register("merchant", name, this.data[name],password , this.data[password], resultObj)
if (res.code == 0) {
wx.navigateTo({
url: '../login/login',
})
} else {
wx.showToast({
title: res.msg,
icon: "none"
})
}

}



});